package org.cfk.delaytasktutorial.util;

import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;

public class TransactionUtils {
    @FunctionalInterface
    public interface AfterCommitCallback {
        void afterCommit();
    }

    public static void runAfterCommit(AfterCommitCallback callback) {
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                callback.afterCommit();
            }
        });
    }
}